<template>
  <view class="applyItem">
    <view class="withdrawItem" @click="toWrite(apply)">
      <view class="title">
        <text>{{$t('salesman.no')}}:{{ apply.business_code }}</text>
        <text class="red">{{ apply.loading_desc }}</text>
      </view>
      <text class="time">{{ apply.created_at }}</text>
      <text class="type">
        {{
          apply.subject_info.subject_type == "SUBJECT_TYPE_INDIVIDUAL"
            ? $t('salesman.subType1')
            : apply.subject_info.subject_type == "SUBJECT_TYPE_ENTERPRISE"
            ? $t('salesman.subType2')
            : apply.subject_info.subject_type == "SUBJECT_TYPE_INSTITUTIONS"
            ? $t('salesman.subType3')
            : $t('salesman.subType4')
        }}
      </text>
      <view class="reasonBox" v-if="apply.status == 2">
        <view class="reason">
          <text class="title">{{$t('salesman.rejected')}}：</text>
          <view class="reasonList">
            <text v-for="(item, index) in reason" :key="index">{{
              item.reject_reason
            }}</text>
          </view>
        </view>
        <view
          class="showMore"
          @click.stop="showMore = !showMore"
          v-if="apply.refuse_desc.length > 1"
        >
          <text v-if="!showMore">{{$t('shareholder.showMore')}}</text>
          <text v-else>{{$t('shareholder.close')}}</text>
          <text class="iconfont icon-arrow-down" v-if="!showMore"></text>
          <text class="iconfont icon-arrow-up" v-else></text>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  props: {
    apply: {
      type: Object,
      default: () => {
        return {};
      },
    },
  },
  data() {
    return {
      // 是否显示更多详情
      showMore: false,
    };
  },
  computed: {
    reason() {
      if (this.apply.status == 2) {
        if (this.apply.refuse_desc.length > 1) {
          if (this.showMore) {
            return this.apply.refuse_desc;
          } else {
            return [this.apply.refuse_desc[0]];
          }
        } else {
          return this.apply.refuse_desc;
        }
      }
    },
  },
  methods: {
    // 跳转填写资料
    toWrite(item) {
      if (item.status == 0 || item.status == 2) {
        if (item.from == 0) {
          uni.navigateTo({
            url: "/salesman/application/application?id=" + item.id,
          });
        }
        if (item.from == 1) {
          uni.navigateTo({
            url: "/salesman/application/chooseType?id=" + item.id,
          });
        }
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.withdrawItem {
  background-color: #fff;
  margin-top: 24rpx;
  display: flex;
  flex-direction: column;
  padding: 30rpx;
  .title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 24rpx;
    color: #8c8c8c;
    text:nth-child(1) {
      font-size: 28rpx;
      color: #262626;
      font-weight: 600;
    }
    .red {
      color: #f0250e;
    }
  }
  .time {
    font-size: 24rpx;
    color: #8c8c8c;
    margin: 10rpx 0;
  }
  .type {
    font-size: 24rpx;
    color: #8c8c8c;
  }
  .reasonBox {
    margin-top: 10rpx;
    font-size: 24rpx;
    color: #8c8c8c;
    .reason {
      display: flex;
      align-items: flex-start;
      .title {
        min-width: 140rpx;
      }
      .reasonList {
        display: flex;
        flex-direction: column;
      }
    }
    .showMore {
      display: flex;
      align-items: center;
      font-size: 24rpx;
      color: #8c8c8c;
      justify-content: center;
    }
  }
}
</style>